<template>
	<view>
		<cu-custom :bgcolor="'#fff'" />
		<view>
			<scroll-view scroll-y="true" :style="'height:'+scorllHeight+ 'px;'">
				<view class="" v-if="finance">
					<view class="h-100 text-center pt-5" v-if="erpInfo.examine == 0">
						<text>信息审核中, 请稍后再试</text>
					</view>
					<view class="h-100" v-if="erpInfo.examine == 1">
						<view class="d-flex flex-column p-2">
							<text>账号: {{erpInfo.username}}</text>
							<text>密码: {{erpInfo.password}}</text>
							<text>网站地址: </text>
							<text>{{erpInfo.url}}</text>
						</view>
					</view>
					<view class="h-100 text-center pt-5" v-if="erpInfo.examine == 2">
						<text>审核失败,请联系客服</text>
					</view>
				</view>
				<view v-else class="h-100 text-center pt-5">
					<text>您还没有申请财务系统使用权限, <text class="main-text-color" @click="toApplication">点击申请</text></text>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import title from "@/components/common/title.vue"
	import divider from "@/components/common/divider.vue"
	import cuCustom from '@/components/common/custom.vue'
	import interceptor from "@/utils/request.js"
	export default {
		components: {
			title,
			divider,
			cuCustom
		},
		data() {
			return {
				value: 0,
				scorllHeight: 500,
				erpInfo:"",
				finance: false
			}
		},
		onLoad() {
			uni.getSystemInfo({
				success: (res => {
					this.scorllHeight = res.windowHeight - uni.upx2px(180)
				})
			})
			this.getStoreBase()
		},
		onShow() {
			
		},
		methods: {
			// 获取详情
			getStoreBase() {
				let params = {
					supplier_id: uni.getStorageSync("supplier_id"),
					user_id: uni.getStorageSync("USER_ID")
				}
				interceptor.get("/supplier_applet_api.php?act=userInfo", params).then((res) => {
					if (res.status == 1) {
						// 已提交过申请
						if(res.info.finance){
							this.finance = true
							this.erpInfo = res.info.finance
						}else {
							this.finance = false
						}
						
						this.$forceUpdate()
					} else {
						uni.showToast({
							title: res.msg,
							icon: "none"
						})
					}
				})
			},
			toApplication(){
				let _that = this
				interceptor.get('/supplier_applet_api.php?act=applyFinanceSystem', {
					supplier_id: uni.getStorageSync('supplier_id')
				}).then((res) => {
					if (res.status === 1) {
						uni.showToast({
							title: res.msg,
							icon: "none",
							success() {
								_that.getStoreBase()
							}
						})
					} else {
						uni.showToast({
							title: res.msg,
							icon: "error"
						})
					}
				})
				
			}

		}
	}
</script>

<style scoped lang="scss">
	.search-box {
		width: 100%;
		height: 160upx;
		background: #fff;

		box-sizing: border-box;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;

		.input {
			width: 90%;
			border-radius: 20px;
			overflow: hidden;
			border: 1px solid #BBBBBB;
			position: relative;

			.icon-sousuo {
				position: absolute;
				left: 35upx;
				top: 10upx;
			}

			.search {
				position: absolute;
				right: 40upx;
				top: 8upx;
			}
		}
	}

	.shop-list {
		background: #EBECED;
		height: auto;
		padding: 32rpx;
		box-sizing: border-box;

		.list-box {
			background: #FFFFFF;
			border-radius: 20rpx;
			height: auto;

			.list {
				height: auto;
				border-bottom: 1px dashed #dcdcdc;
			}

			.list-btn {}
		}

	}
</style>